<?php

include_once 'CodeObject.php';
include_once 'ImportType.php';

class Import extends CodeObject
{
    public function __construct($fileName, $importType)
    {
        $this->set_fileName($fileName);
        $this->set_importType($importType);
    }
    public function get_fileName()
    {
        return $this->fileName;
    }

    public function set_fileName($fileName)
    {
        if(is_string($fileName))
        {
            if(strlen($fileName) > 0)
            {
                $this->fileName = $fileName;
            }
            else
            {
                throw new InvalidArgumentException(
                    'The file name can not be an empty string');
            }
        }
        else
        {
            throw new InvalidArgumentException(
                'The file name must be a string');
        }
    }

    public function get_importType()
    {
        return $this->importType;
    }

    public function set_importType($importType)
    {
        if((strcmp($importType, ImportType::C_INCLUDE) != 0 )
           && (strcmp($importType, ImportType::C_INCLUDE_ONCE) != 0)
           && (strcmp($importType, ImportType::C_REQUIRE) != 0)
           && (strcmp($importType, ImportType::C_REQUIRE_ONCE) !=0))
        {
            throw new InvalidArgumentException(
                "Invalid import type: $importType");
        }
        
        $this->importType = $importType;
    }

        
    private $fileName;
    private $importType;
}

?>
